import { Http } from "@/utils/request";
import { Toast } from "@/utils/toast";
import { delayTask } from "@/utils/timer";

const baseUrl = "/v3";


export const get_require_index = (
  data: { search_type?:0| 1 | 2 ,end_area_id?:number, keyword?:string,type:number} & MiniApp.PagingQuery,
  showError = true
) => {
  return Http.post<MiniApp.PagingData>(`${baseUrl}/new_guide/travel_agency_task_index_list`, data).catch(
    (error: Error) => {
      showError && delayTask(60, () => Toast.show(error.message));
      return Promise.reject(error);
    }
  );
};
export const get_require_detail = (id: number, showError = true) => {
  return Http.get<any>(`${baseUrl}/new_guide/travel_agency_task_guide_info`, { id }).catch(
    (error: Error) => {
      showError && delayTask(60, () => Toast.show(error.message));
      return Promise.reject(error);
    }
  );
};
export const task_index_header = ( showError = true) => {
  return Http.get<any>(`${baseUrl}/new_guide/travel_agency_task_index_header`).catch(
    (error: Error) => {
      showError && delayTask(60, () => Toast.show(error.message));
      return Promise.reject(error);
    }
  );
};
const baseUrl2 = "/destination";

export const filter_api = (showError = true) => {
  return Http.get<any>(`${baseUrl2}/filter/0`).catch((error: Error) => {
    showError && delayTask(60, () => Toast.show(error.message));
    return Promise.reject(error);
  });
};


